package edu.hunau.cxb19.oop.class21;

import java.util.ArrayList;
import java.util.List;

import edu.hunau.cxb19.oop.class21.lambda.AppleFilter;

/**
 * 对苹果进行过滤
 * 
 * @author hb
 *
 *         2020-03-24 16:06:59
 */
public class AppleService {

	/*
	 * public List<Apple> filterByColor(String color){ return null; }
	 * 
	 * public List<Apple> filterByWeight(int weight){ return null; }
	 */

	public static List<Apple> filter(List<Apple> lists, AppleFilter filter) {
		List<Apple> datas = new ArrayList<Apple>();
		for (Apple apple : lists) {
			if (filter.test(apple)) {
				datas.add(apple);
			}
		}
		return datas;

	}

}
